package com.personal.persistence.sqlSession;

import java.beans.PropertyVetoException;
import java.io.InputStream;

import org.dom4j.DocumentException;

import com.personal.persistence.config.XmlConfigBuilder;
import com.personal.persistence.pojo.Configuration;

public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream inputStream) throws DocumentException, PropertyVetoException {
        // 解析配置文件封装到Configuration
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        // 生产sqlSessionFactory对象
        return new DefaultSqlSessionFactory(configuration);
    }
}
